<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" v-model="info" placeholder="请输入1-100整数">
    <input type="button" value="猜一猜" @click="f()">
    <h3>{{result}}</h3>
</div>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let x = parseInt(Math.random()*100)+1;
    let count=0;
    let v = new Vue({
        el:"div",
        data:{
            info:"",
            result:""
        },
        methods:{
            f:function () {
                if (isNaN(v.info)){
                    v.result="输入错误!";
                    return;
                }
                count++;
               if (v.info>x){
                    v.result="猜大了!";
               } else if (v.info<x){
                   v.result="猜小了!";
               }else{
                   v.result="恭喜你第"+count+"次猜对了!";
               }
            }
        }

    })
</script>
</body>
</html>